package com.atguigu.yygh.cmn.excel;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;

/**
 * @author mgx
 * @version 1.0
 * @description: TODO
 * @date 2022/8/23 22:05
 */
public class EasyExcelReadDemo {

    // 方式二：读取多个sheet
    public static void main(String[] args) {
        ExcelReader build = EasyExcel.read("D:\\java_projects\\syt_yygh\\student.xlsx").build();
        ReadSheet sheet1 = EasyExcel.readSheet(0).head(Student.class).registerReadListener(new StudentListener()).build();
        ReadSheet sheet2 = EasyExcel.readSheet(1).head(Student.class).registerReadListener(new StudentListener()).build();
        // 批量读取
        build.read(sheet1, sheet2);
        // 关闭资源
        build.finish();
    }


    // 方式一: 简单读取
   /* public static void main(String[] args) {
        *//**
         * 参数说明：
         *      1.读取文件路径
         *      2.解析对象
         *      3.监听器
         *//*
        EasyExcel.read("D:\\java_projects\\syt_yygh\\student.xlsx", Student.class, new StudentListener())
                .sheet(0).doRead();
    }*/
}
